/*
 * VHSelector.java
 * Created on 12 juil. 2009
 *
 * VirtualHockey Internet Platform
 * http://code.google.com/p/virtualhockey/
 *
 * Copyright (c) 2005-2009, Jens and Jan Janke (VirtualHockey Project)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 */

package com.hockeo.vhweb.client.ui.base;

import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.hockeo.vhweb.client.utils.VHJsData;

/**
 * Base class for all combo box derived selectors.
 *
 * @version $Id$
 * @author jjanke
 */
public abstract class VHSelector extends LayoutContainer
{
  private final ListStore<VHJsData> d_store;
  private final ComboBox<VHJsData>  d_combobox;
  private boolean                   d_fInitialised = false;

  protected VHSelector()
  {
    d_store = new ListStore<VHJsData>();
    d_combobox = new ComboBox<VHJsData>();

    d_combobox.setStore( d_store );
    d_combobox.setLazyRender( true );
    d_combobox.setEditable( false );
    d_combobox.setAllowBlank( false );
    d_combobox.setForceSelection( true );
    d_combobox.setTriggerAction( TriggerAction.ALL );

    add( d_combobox );
  }

  /**
   * Indicates whether the underlying data store has been loaded at least once.
   */
  public final boolean isInitialised()
  {
    return d_fInitialised;
  }

  protected final void setInitialised( boolean flag )
  {
    d_fInitialised = flag;
  }

  protected final ListStore<VHJsData> getStore()
  {
    return d_store;
  }

  public final ComboBox<VHJsData> getCombobox()
  {
    return d_combobox;
  }
}
